<!--
 * @Descripttion:
 * @version: @ 1.0.0
 * @Author: ZJZ
 * @Date: 2021-05-20 16:39:02
 * @LastEditors: 朱江洲
 * @LastEditTime: 2021-11-01 14:24:18
-->

<template>
  <div>
    <el-drawer
      title="证书维护"
      :visible.sync="dialog.dialogShowDrawer"
      :direction="direction"
      :with-header="false"
      size="60%"
      :modal="false"
      @close="drawerClose"
    >
      <div class="head">
        <div class="header">
          <div class="img">
            <img src="@/assets/images/icon-people.png" alt=""/>
            <h3>资质名称</h3>
          </div>
          <div class="btn">
            <el-dropdown>
              <el-button class="el-icon-more"></el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item v-hasPermi="['register:management:del']">
                  删除
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
        <div class="footer">
          <div class="information">
            <span>公司名称</span>
            <h4>{{ drawerData.companyName }}</h4>
          </div>
          <div class="information">
            <span>有效期</span>
            <h4>{{ drawerData.certValidity }}</h4>
          </div>
          <div class="information">
            <span>发证机关</span>
            <h4>{{ drawerData.issueUnit }}</h4>
          </div>
          <div class="information">
            <span>发证时间</span>
            <h4>{{ drawerData.issueDate }}</h4>
          </div>
        </div>
      </div>
      <div class="strip"></div>
      <div class="specific">
        <el-tabs v-model="activeName" type="border-card">
          <el-tab-pane label="详细资料" name="first">
            <div class="basics">基础信息</div>
            <div class="basics-information">
              <div class="subclass">
                <span>证书编码：{{ drawerData.certNumber }}</span>
              </div>
              <div class="subclass">
                <span>状态：{{ drawerData.foreverValidity == 'Y'?"未过期":compareDate(drawerData.validityDate)?'未过期':"已过期"  }}</span>
              </div>
              <div class="subclass">
                <span>备注：{{ drawerData.备注 }}</span>
              </div>
            </div>
            <div class="system">系统信息</div>
            <div class="basics-information">
              <div class="subclass">
                <span>创建人：{{ drawerData.createBy }}</span>
              </div>
              <div class="subclass">
                <span>负责人：{{ drawerData.directorName }}</span>
              </div>
              <div class="subclass">
                <span>创建时间：{{ drawerData.createTime }}</span>
              </div>
              <div class="subclass">
                <span>更新时间：{{ drawerData.updateTime }}</span>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="操作记录" name="third" class="thirdTab">
            <div
              class="operation"
              v-for="(item, index) in Operation"
              :key="index"
            >
              <div class="user">
                <div class="portrait">
                  <img :src="item.avatar" alt=""/>
                </div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.createBy"
                  placement="top"
                >
                  <div class="name">{{ item.createBy }}</div>
                </el-tooltip>
              </div>
              <div class="record">
                <div class="time">{{ item.createTime }}</div>
                <div class="content">
                  <div>{{ item.content }}</div>
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import { getInfo } from '@/api/registration'
import { OperationRecord } from '@/api/currency'

export default {
  props: {
    dialog: {
      type: Object,
      required: true
    },
    drawerData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      Operation: [],
      examinationList: {
        place: '浙江省杭州市上城区自强街743号',
        examinationName: '**********',
        admission: '3712893',
        starttime: '2021/2/13',
        endtime: '2021/5/24',
        school: '***********',
        contacts: '闵羽英',
        contactInformation: '19949300977',
        careful: '假话全不说，真话不全说',
        adopt: '未通过'
      },
      activeName: 'first',
      direction: 'rtl',
      stuInfo: []
    }
  },
  created() {
  },
  watch: {
    drawerData: {
      deep: true,
      handler() {
        if (this.drawerData !== {}) {
          this.getRecord()
          this.getStuInfo()
        }
      }
    }
  },
  methods: {
    drawerClose() {
      this.dialog.dialogShowDrawerEject = false
    },
    // 获取操作记录
    getRecord() {
      OperationRecord({ columnId: 9, entryId: this.drawerData.id }).then(
        (res) => {
          this.Operation = res.data
        }
      )
    },
    edit() {
      this.dialog.dialogDrawerShow = true
    },
    del() {
    },
    getStuInfo() {
      getInfo({
        batchId: this.drawerData.batchId,
        personId: this.drawerData.personId
      }).then((res) => {
        this.stuInfo = res.data
      })
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .el-drawer.rtl {
  height: 96%;
  margin-top: 4%;
}

.head {
  padding: 29px;
  width: 100%;
  height: 155px;
  border-bottom: 1px solid #ececec;

  span {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
  }

  .header {
    display: flex;
    justify-content: space-between;

    .img {
      transform: translateY(-15px);

      img {
        vertical-align: middle;
        margin-right: 12px;
      }

      h3 {
        display: inline-block;
      }
    }
  }

  .footer {
    display: flex;

    .information {
      display: flex;
      flex-direction: column;
      margin-right: 80px;

      h4 {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #2b2b2b;
        margin-top: 12px;
      }
    }
  }
}

.strip {
  width: 100%;
  height: 16px;
  background: #fafafa;
  border: 1px solid #ececec;

  /deep/ .el-tabs__nav-scroll {
    background-color: #f5f8fa;
  }
}

/deep/ .el-tab-pane {
  padding-left: 24px;
}

.basics {
  position: relative;
  font-size: 14px;
}

.basics::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 3px;
  width: 3px;
  height: 14px;
  background: #1267fa;
}

.system {
  margin-top: 40px;
  position: relative;
  font-size: 14px;
}

.system::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 3px;
  width: 3px;
  height: 14px;
  background: #1267fa;
}

.basics-information {
  display: flex;
  flex-wrap: wrap;

  .subclass {
    width: 249px;
    margin-top: 30px;
    margin-right: 150px;

    span {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 14px;
    }
  }
}

.operation {
  display: flex;

  .user {
    display: flex;

    .portrait {
      width: 30px;
      height: 30px;
      border-radius: 30px;

      img {
        width: 100%;
        height: 100%;
        border-radius: 30px;
      }
    }

    .name {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      width: 100px;
      height: 30px;
      line-height: 30px;
      margin-left: 14px;
    }
  }

  .record {
    padding-left: 21px;
    margin-left: 44px;
    border-left: 1px dotted #dbdcdb;

    .time {
      font-size: 14px;
      position: relative;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 14px;
    }

    .time::before {
      content: "";
      position: absolute;
      left: -27px;
      width: 11px;
      height: 11px;
      background-color: #000;
      transform: rotate(45deg);
    }

    .content {
      padding-top: 10px;
      padding-bottom: 10px;
    }
  }
}

.el-dropdown {
  margin-left: 10px;
}

/deep/ .thirdTab {
  .el-tabs__content {
    height: 100vh;
  }
}

/deep/ .el-table__header-wrapper {
  background: #f2f2f2;
}

/deep/ .el-tabs__content {
  height: 100vh;
}

.imgUp {
  width: 100px;
  height: 100px;
  vertical-align: top;
}

/deep/ .el-tabs__content {
  overflow: auto;
}
</style>
